<#macro brandSelect name="car.brand.id" class="">
<#if brandList ??>
<#--以json格式保存大品牌下的每个子品牌-->
<select id="brandSelect" class="dfinput brandSelect ${class}">
	<option value="0">请选择</option>
	<#list brandList as b>
	<option value="${b.id}" sons="<#list b.children as bc>{'id':${bc.id},'name':'${bc.name}'},</#list>">${b.firstLetter}-${b.name}</option>
	</#list>
</select>
<select id="brandSonSelect" name="${name}" class="dfinput brandSelect ${class}">
	<option value="0">请选择</option>
</select>

<script>
$(document).ready(function(){
	$("#brandSelect").change(function(){
		var sons = "";
		if($(this).val() <=0){
			sons = "{'id':0,'name':'请选择'}";
		}else{
			sons = $(this).find("option:selected").attr("sons");
			if(sons.length>1)
				sons = sons.substring(0, sons.length-1);
		}
		try{
			var sonList = eval("(["+sons+"])");
			var sonSelect = document.getElementById("brandSonSelect");
			var opts = sonSelect.options;		
			opts.length = 0;					//清空
			for(var i=0;i<sonList.length;i++){
				opts[opts.length] = new Option(sonList[i].name, sonList[i].id);
			}
		}catch(e){}
	});
});
</script>
<#else>
<script>alert("没有brandList数据！想要调用品牌选择模板，那么Controller需要经过brandSelectInterceptor 才能获取到数据");</script>
</#if>
</#macro>